function WeiPsi(psi, viewDate) {
	this.psi = psi;
	viewDate.setDate(1);
	this.viewDate = viewDate;
	this.waveCrest = 100;
	this.oneDay = 1000 * 3600 * 24;
	this.today = new Date().format('yyyy年MM月dd日');
}

WeiPsi.prototype.viewDateLastDay = function() {
	var viewYearMonthDate = this.viewDate.format('yyyy-MM-dd').split("-");
	var year = viewYearMonthDate[0];
	var month = viewYearMonthDate[1];

	var newYear = year;
	var newMonth = month++;
	if (month > 12) {
		newMonth -= 12;
		newYear++;
	}
	var newDate = new Date(newYear, newMonth, 1);
	return (new Date(newDate.getTime() - this.oneDay)).getDate();
}

WeiPsi.prototype.caclePsi = function(lastDay, psiCycle) {
	var datas = [];
	var dtDays = dateDiff(this.psi.birthday, this.viewDate.format('yyyy-MM-dd')) - 1;
	for (var i = 1; i <= lastDay; i++) {
		var data = (this.waveCrest * Math.sin(2 * Math.PI * (dtDays + i) / Math.round(psiCycle))).toFixed(0);
		datas.push(data == -0 ? 0 : data);
	}
	return datas;
}

WeiPsi.prototype.seriesData = function() {
	this.xAxisData = [];
	var lastDay = this.viewDateLastDay();
	for (var i = 1; i <= lastDay; i++) {
		this.xAxisData.push(i);
	}

	var bs = this.psi.birthday.split("-");
	this.lunar = calendar.solar2lunar(parseInt(bs[0]), parseInt(bs[1]), parseInt(bs[2]));

	var now = new Date();
	var nowYear = now.getFullYear();
	var nowMonth = now.getMonth() + 1;
	var nowDate = now.getDate();
	this.life = dateDiff(this.psi.birthday, nowYear + "-" + nowMonth + "-" + nowDate) - 1;

	this.seriesData = {};
	this.seriesData.physical = this.caclePsi(lastDay, 23.0);
	this.seriesData.sensitive = this.caclePsi(lastDay, 28.0);
	this.seriesData.intellectual = this.caclePsi(lastDay, 33.0);
}